package com.third.mapper;
import org.apache.ibatis.annotations.*;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.third.entity.OutboundOrder;
import com.third.entity.Quality;

import java.util.HashMap;
import java.util.List;
@Mapper
public interface QualityMapper extends BaseMapper<Quality> {

    @Select("<script>"+
            "select *,b.brand_id "+
            "from outbound_order o,brand b,user u"+
            "<where>"+
            "o.customer_id=u.user_id and o.brand_id=b.brand_id "+
            "<if test='brandName !=null and brandName!=\"\"'>"+
            "and b.brand_name like CONCAT('%', #{brandName}, '%') "+
            "</if>"+
            "<if test= 'userName !=null and userName!=\"\"'>"+
            "and u.username like CONCAT('%', #{userName}, '%') "+
            "</if>"+
            "<if test= 'orderId !=null and orderId!=\"\"'>"+
            "and o.order_id like CONCAT('%', #{orderId}, '%')  "+
            "</if>"+
            "</where>"+
            " ORDER BY o.order_id "+
            "limit #{start},#{size}"+
            "</script>")
    @Results({
            @Result(property = "orderId",column = "order_id"),
            @Result(property = "orderDate",column = "order_date"),
            @Result(property = "orderType",column = "order_type"),
            @Result(property = "user.userId",column = "user_id"),
            @Result(property = "user.username",column = "username"),
            @Result(property = "brand.brandName",column = "brand_name"),
            @Result(property = "brand.brandId",column = "brand_id"),
            @Result(property = "brand.specification",column = "specification"),
            @Result(property = "permission",column = "permission")
    })
    List<Quality> getList(HashMap<String,Object> map);
}